Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ENH: polish scripts (error handling, paths) #22

Merged
merged 8 commits into from
Mar 28, 2024

Conversation

ZLLentz
Copy link
Member

@ZLLentz ZLLentz commented Mar 27, 2024

Description

This PR doesn't change the workflows at all, but makes small changes to the bash scripts for maintenance and consistency.

Changes:

  • Remove the incorrect/incomplete python environment checks, replacing them with always sourcing the correct env (with an environment variable override option).
  • Define the correct python env in a central file (activate_python.sh) instead of in each script that needs it.
  • Centralize the path definitions in a central file (paths.sh) instead of in each script that needs them.
  • Also in paths.sh, cd to the ansible root because this is the only directory where the ansible scripts work properly. This will let us effectively run the scripts from anywhere, which was previously intended but not possible.
  • Make all the scripts exit on failure and do the ssh agent cleanup regardless of when they fail, using set -e and trap

Motivation and Context

  • I noticed that the python env sourcing wasn't quite correct
  • I noticed that the ssh agent would sometimes not be cleaned up if a script exited early
  • I noticed that some of the scripts would continue onward despite an issue
  • I noticed that the scripts could only be run from the ansible root

And I wanted to fix all of these.

How Has This Been Tested?

Interactively from a fresh BSD install and from already set up test PLCs.

Where Has This Been Documented?

I'm not intending to add anything to the docs, this is business as usual but with edge case bugfixing.

Pre-merge checklist

@ZLLentz ZLLentz requested review from ghalym and nrwslac March 27, 2024 18:43
Copy link

@ghalym ghalym left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm!

Copy link

@slactjohnson slactjohnson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

source "${ANSIBLE_PYTHON_ACTIVATE}"
else
echo "No Python activation script found at ${ANSIBLE_PYTHON_ACTIVATE}"
return 1

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nitpick: Shouldn't we also return 0 if ANSIBLE_PYTHON_ACTIVATE was found?

Copy link
Member Author

@ZLLentz ZLLentz Mar 28, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

return 0 is implied, when the script rolls off the end without erroring or returning early

@ZLLentz ZLLentz merged commit a066f86 into pcdshub:master Mar 28, 2024
1 check passed
@ZLLentz ZLLentz deleted the enh_check_python branch March 28, 2024 01:21
@ZLLentz ZLLentz mentioned this pull request Mar 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants